home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 3_7.lha / 3_7 / 3_7f.c < prev    next >
Text File  |  1993-08-08  |  587b  |  27 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. /    Compare two strings. Return <0, >0 or 0
  6. /    when the first string is lexically
  7. /    less than, greater than, or equal to
  8. /    the second, respectively.
  9.  
  10. nt strcmp(const char *s1, const char *s2)
  11.  
  12.    if (s1 && s2)
  13. {
  14. while (*s1)
  15.     if (*s1++ != *s2++)
  16. ifdef TSTG        /* DELETE */
  17.  include "3_7g.c"    /* DELETE */
  18. else            /* DELETE */
  19.     return s1[-1] - s2[-1];
  20. endif            /* DELETE */
  21. return *s1 - *s2;
  22. }
  23.  
  24.    else
  25. error("NULL pointer encountered");
  26.  
  27.